/*
 * hdu 1025
 * 请求序列构成按序增加即可达到连线不相交，序列长度即题目解，因此题目转化为求最长上升子序列问题。
 * 注意：仅有一条路时，为road，否则为roads。
 */
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stdlib.h>
int lis(int *data, int *seq, int n)
{
    int up,low,len,mid;
    seq[1]=data[1];
    len=1;

    //二分查找插入
    for(int i = 2; i<=n; i++)
    {
        low=1;
        up=len;
        while (low<=up) {
            mid=(low+up)>>1;
            if(seq[mid]<data[i])low=mid+1;
            else up=mid-1;
        }
        seq[low]=data[i];
        if(low>len)len++;
    }
    return len;

}
int data[500005],seq[500005];
int main()
{
    int n,a,b;
    int count = 1;
    while (std::cin>>n) {
        //memset(data, 0, 4*500001);
        for(int i = 0; i < n; i++)
        {
            scanf("%d%d",&a,&b);//使用std::cin超时，OJ编译器优化有问题
            data[a]=b;
        }
        int size = 0;
        size=lis(data, seq, n);
        if(size!=1)
            printf("Case %d:\nMy king, at most %d roads can be built.\n\n",count++,size);
        else
            printf("Case %d:\nMy king, at most %d road can be built.\n\n",count++,size);

    }
    return 0;
}
